<!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
		<meta http-equiv="content-script-type" content="text/javascript">
		<meta http-equiv="content-style-type" content="text/css">
		<meta name="author" content="Heidi Rakels">
		<meta name="description" content="Sanaware Java Docking - Developer guide - Docking Paths">
		<link rel="stylesheet" type="text/css" href="../style.css">
		<title>How to Use Docking Paths</title>
	</head>
<body>

<div class="nextprev">
<nobr><a href="dockmodel.html">&laquo; prev</a></nobr>
<nobr><a href="codec.html">next &raquo;</a></nobr>
</div>

<span class="item"><a href="../main/index.html">Java Docking Home</a></span>&gt;
<span class="item"><a href="index.html">Developer Guide</a></span>&gt;
<span class="selected item">How to Use Docking Paths</span>

<h2>
How to Use Docking Paths
</h2>

<h3>
:: Keeping the history about a dockable in a docking path ::
</h3>
<p>
When you don't need a dockable anymore, you can close it. It will be removed from the dock model.

It is possible that, later, you want to display the content of the dockable again.
Normally you want to put the dockable again, where it was, when it was removed.
This is possible by using <a href="../javadoc/com/javadocking/model/DockingPath.html" target="_blank">
DockingPath</a>s.

A docking path keeps all the information about, where the dockable is in a dock model.
<blockquote><pre>
		DockingPath dockingPath = DefaultDockingPath.createDockingPath(dockable, dockModel);
</pre></blockquote>
</p>

<a name="DockingPathModel"><!-- --></a>
<h3>
:: Docking Path Model ::
</h3>
<p>
The <a href="../javadoc/com/javadocking/model/DockingPathModel.html" target="_blank">DockingPathModel</a> 
of the <a href="../javadoc/com/javadocking/DockingManager.html" target="_blank">DockingManager</a>
will keep track of all your docking paths:
<blockquote><pre>
		DockingPathModel dockingPathModel = DockingManager.getDockingPathModel();
</pre></blockquote>
Add all your docking paths to the docking path model:
<blockquote><pre>
		dockingPathModel.add(dockingPath);
</pre></blockquote>
</p>

<a name="DockableStateAction"><!-- --></a>
<h3>
:: Dockable State Action ::
</h3>
<p>
When you close a dockable with a 
<a href="../javadoc/com/javadocking/dockable/action/DefaultDockableStateAction.html" target="_blank">DefaultDockableStateAction</a>
a docking path will be created. It contains the information, where the dockable is docked now in the dock model.
This docking path is added to the docking path model of the docking manager.
When the dockable is restored with a dockable state action, it will be docked as good as possible where it was docked before.
<blockquote><pre>
		...
			closeAction = new DefaultDockableStateAction(dockable, DockableState.CLOSED);
			restoreAction = new DefaultDockableStateAction(dockable, DockableState.NORMAL);
		...
			// Close the dockable.
			closeAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Close"));
		...
			// Restore the dockable.
			restoreAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Restore"));
</pre></blockquote>
</p>
<p>
When you want to use the restore action for a dockable that was not already docked in the dock model,
you have to create a docking path for the dockable by your self. You can create that docking path by using 
the positions of a dockable that is already docked in the dock model.
<blockquote><pre>
			// Add the path of the dockables that are not docked already.
			// We want dockable 5 to be docked, when it is made visible, where dockable 1 is docked.
			DockingPath dockingPathToCopy1 = DockingManager.getDockingPathModel().getDockingPath(dockable1.getID());
			DockingPath dockingPath5 = DefaultDockingPath.copyDockingPath(dockable5, dockingPathToCopy1);
			DockingManager.getDockingPathModel().add(dockingPath5);
</pre></blockquote>
</p>

<hr>

<br/>
The source code of the samples can be found in:
<br/><br/>
<table>
<tr>
	<td><a href="code/CodecExample.java.html">CodecExample</a></td><td>Shows the usage, encoding and decoding of dock models.</td>
</tr>
<tr>
	<td><a href="code/WorkspaceExample.java.html">WorkspaceExample</a></td><td>Shows the usage, the encoding, and the decoding of dock models.</td>
</tr>
</table>

<br/>
<hr>
<br/>

<div class="nextprevbottom">
<nobr><a href="dockmodel.html">&laquo; prev</a></nobr>
<nobr><a href="codec.html">next &raquo;</a></nobr>
</div>

</body>

</html>